#ifndef RR_CONFIG_H_
#define RR_CONFIG_H_
#include <string>
#include <map>

class RrConfig
{
public:
	RrConfig()
	{
	}
	~RrConfig()
	{
	}
	bool ReadConfig(const std::string& filename);
	std::string ReadString(const char* section, const char* item, const char* default_value);
	int ReadInt(const char* section, const char* item, const int& default_value);
	float ReadFloat(const char* section, const char* item, const float& default_value);
private:
	bool IsSpace(char c);
	bool IsCommentChar(char c);
	void Trim(std::string& str);
	bool AnalyseLine(const std::string& line, std::string& section, std::string& key, std::string& value);

private:
	//std::map<std::string, std::string> settings_;
	std::map<std::string, std::map<std::string, std::string> >settings_;
};



class RrConfigMgr
{
protected:
	RrConfigMgr();

public:
	static RrConfigMgr& GetInstance();

	std::string ReadString(const char* section, const char* item, const char* default_value);
	int ReadInt(const char* section, const char* item, const int& default_value);
	float ReadFloat(const char* section, const char* item, const float& default_value);
	virtual ~RrConfigMgr();

private:
	static RrConfigMgr m_oInstance;
	RrConfig config;

};


#endif

/*
#include <stdio.h>
#include "RrConfig.h"
int main()
{
	int port  = RrConfigMgr::GetInstance().ReadInt("MYSQL", "Port", 0);
	std::string HostName = RrConfigMgr::GetInstance().ReadString("MYSQL", "HostName", "");
	float Scale = RrConfigMgr::GetInstance().ReadFloat("MYSQL", "Scale", 10.01);

	printf("prot:%d HostName:%s Scale:%f .. \n", port, HostName.c_str(), Scale);
	return 0;
}

*/
